package com.itheima.reggie.common;

public class UserHolder {
    /**
     * 存值
     */
    private static final ThreadLocal THREAD_LOCAL = new ThreadLocal();
    public static void setUserId(Long userId){
        THREAD_LOCAL.set(userId);
    }

    /**
     * 取值
     * @return
     */
    public static Long getUserId(){
        Long userId = (Long) THREAD_LOCAL.get();
        return userId;
    }

    /**
     * 释放
     */
    public static void release(){
        THREAD_LOCAL.remove();
    }
}
